package mBio;

import java.io.FileNotFoundException;
import java.io.IOException;

import rfBio.*;

public class longest_orf {

	public static void main(String[] args)
	 throws IOException, FileNotFoundException{
		

		Bioutil test = new Bioutil();
		
		if(args.length != 3){
			System.out.println("Wrong number of parameters!" + '\n' + "Usage: longest_orf infile outfile limit(aa).");
			System.exit(0);
			
		}
		
		fasta f = new fasta(args[0]);
		System.out.println("Read " + f.num_seq()+ " sequences successfully");
		f.set_type("d");

		fasta orfs = new fasta();
				
		for(int i =0; i < f.num_seq(); i++){
			fasta_seq temp_fasta_seq = new fasta_seq(f.get_fasta(i));
			fasta_seq ts = new fasta_seq(temp_fasta_seq.get_longest_orf());
			if(ts.length() >= Type.toInt(args[2])){
				orfs.add_fasta(new fasta_seq(ts));
			}

		}
		orfs.writeFasta(args[1]);
		System.out.println("Found " + orfs.num_seq() + " sequences with ORFs longer than " + args[2]+ ".");
	}
	
}
